package com.controller.base;

import com.model.FrontUser;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpSession;

public class BaseFrontController extends BaseController {


    private ServletRequestAttributes getRequestAttributes() {
        return (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    }

    public HttpSession getSession() {
        return getRequestAttributes().getRequest().getSession();
    }

    public FrontUser getUser() {
        return (FrontUser) this.getSession().getAttribute("front_user");
    }

    public void removeUserSession() {
        getSession().removeAttribute("front_user");
    }
}
